class Solution(object):
    def searchMatrix(self, matrix, target):
        """
        :type matrix: List[List[int]]
        :type target: int
        :rtype: bool
        """
        m = len(matrix)
        n = len(matrix[0]) if m else 0
        if m == 0:
            return False
        row = m-1
        col = 0
        while row >= 0 and col < n:
            print('row is %d, col is %d' % (row, col))
            if matrix[row][col] == target:
                return True
            elif matrix[row][col] < target:
                col += 1
            else:
                row -= 1
        return False
        # 从左下角或者右上角开始找，这里选择左下角


test = Solution()
print(test.searchMatrix([[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]]
, 20))